package se.chalmers.tda366.crumble.gui.components;

import java.awt.Color;
import java.awt.Component;
import java.util.List;

import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.LineBorder;

import se.chalmers.tda366.crumble.core.IArticle;


public class TopArticlesPanel extends JPanel{

	public TopArticlesPanel(List<IArticle> list){
		List<IArticle> articleList=list;
		
		this.setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
		this.setBackground(Color.white);
		this.setBorder(new LineBorder(Color.black, 1));
		this.add(new JLabel("Top articles"));
				
		int i=1;
		
		for(IArticle a:articleList){
			ArticleListItem temp = new ArticleListItem(i + ". " + a.getHeadline(), a);
			temp.setAlignmentX(Component.LEFT_ALIGNMENT);
			this.add(temp);
			//this.add(new ArticleListItem(i + ". " + a.getHeadline(), a));
			i++;
		}

	}
}
